package com.sgq.vue.service.email.impl;

import com.sgq.vue.config.ConstantPropertiesForEmail;
import com.sgq.vue.service.email.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 * @author: 83778
 * @date: 2023-12-16 20:01
 * @desc:
 */
@Service
public class EmailServiceImpl implements EmailService {

    @Value("${spring.mail.username}")
    private String from;

    @Autowired
    private JavaMailSender mailSender;

    @Override
    public void send(String target, String title, String content){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(from);
        message.setTo(target);
        message.setSubject(title);
        message.setText(content);
        mailSender.send(message);
    }
}
